//
//  BillingDetailsVC.m
//  Logistics
//
//  Created by enzhoukeji on 2018/8/10.
//  Copyright © 2018年 puyue.com. All rights reserved.
//

#import "BillingDetailsVC.h"
#import "BillingDetailsTVCell.h"
@interface BillingDetailsVC ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *recordTV;
@property (nonatomic, strong) NSArray * titleAarray;
@property (nonatomic, strong) NSArray * contentAarray;
@end

@implementation BillingDetailsVC
-(NSArray *)titleAarray {
    if (!_titleAarray) {
        _titleAarray = [NSArray arrayWithObjects:@"付款方式",@"总价",@"实际付款",@"商品",@"商品描述",@"商交易时间",@"交易单号",@"交易商户",nil];
    }
    return _titleAarray;
}
-(NSArray *)contentAarray {
    if (!_contentAarray) {
        _contentAarray = [NSArray arrayWithObjects:@"微信",@"2000",@"150.9",@"轮胎",@"前面轮胎",@"2018-08-33 12：33",@"123i1293i12093i",@"鹏程万里",nil];
    }
    return _contentAarray;
}
-(UITableView *)recordTV{
    if (!_recordTV) {
        _recordTV = [[UITableView alloc]initWithFrame:CGRectMake(0,  kMainTopHeight, kMainScreen_width , kMainScreen_height-kMainTopHeight - GTFixHeightFlaot(37)) style:UITableViewStylePlain];
        _recordTV.showsVerticalScrollIndicator = NO;
        _recordTV.dataSource = self;
        _recordTV.delegate = self;
    }
    return _recordTV;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navTitle = @"账单详情";
    [self.view addSubview:self.recordTV];
    // Do any additional setup after loading the view.
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 8;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    BillingDetailsTVCell *cell=[tableView dequeueReusableCellWithIdentifier:@"BillingDetailsTVCell"];
    if (!cell) {
        cell=[[BillingDetailsTVCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"BillingDetailsTVCell"];
    }
    cell.titleLabel.text = self.titleAarray[indexPath.row];
    cell.contentLabel.text = self.contentAarray[indexPath.row];
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return GTFixHeightFlaot(40);
}
-(void)viewDidLayoutSubviews {
    
    if ([self.recordTV respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.recordTV setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([self.recordTV respondsToSelector:@selector(setLayoutMargins:)])  {
        [self.recordTV setLayoutMargins:UIEdgeInsetsZero];
    }
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPat{
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView * headView = [UIView new];
    headView.backgroundColor = [UIColor whiteColor];
    UILabel * label = [UILabel labelWithSize:[UIFont systemFontOfSize:14] withColor:nil withText:@"交易结束"];
    UILabel * numberLabel = [UILabel labelWithSize:[UIFont systemFontOfSize:25] withColor:nil withText:@"-2000.00"];
    numberLabel.textColor = [UIColor redColor];
     UILabel * labelLin = [UILabel labelWithSize:[UIFont systemFontOfSize:14] withColor:nil withText:nil];
    labelLin.backgroundColor = [UIColor colorWithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1];
    [headView addSubview:label];
    [headView addSubview:numberLabel];
    [headView addSubview:labelLin];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo (GTFixHeightFlaot(15));
        make.left.mas_equalTo(GTFixWidthFlaot(20));
        make.height.mas_equalTo(GTFixHeightFlaot(20));
        make.width.mas_equalTo(label.mas_width);
    }];
    [numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo (label.mas_bottom).offset(GTFixHeightFlaot(5));
        make.left.mas_equalTo(GTFixWidthFlaot(20));
        make.height.mas_equalTo(GTFixHeightFlaot(30));
        make.width.mas_equalTo(numberLabel.mas_width);
    }];
    [labelLin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(0);
        make.left.mas_equalTo(GTFixWidthFlaot(0));
        make.height.mas_equalTo(GTFixHeightFlaot(5));
        make.width.mas_equalTo(kMainScreen_width);
    }];
    return headView;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return GTFixHeightFlaot(80);
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
